|
|
|
|
|
|
|
Internally, Windows can be thought of as a message-processing engine. It receives messages and dispatches others. A message can be generated by the user clicking a window or pressing a key on the keyboard. A message can also be generated by such things as the system clock ticking. These messages are dispatched by Windows to the various objects on the system, including your Visual Basic programs. |
|
|
|
|
|
|
|
|
When a Visual Basic program receives a message, it generates an event. Event-driven programming describes an application that waits for an event and then responds to those events when they happen. Windows continually feeds your program messages that you will handle as events. All windowing operating systems require event-driven programming techniques. |
|
|
|
|
|
|
|
|
An event can be a mouse click, a key press, mail coming into your mailbox, a fax being received in the background, or a timer/alarm clock going off. An event may even be triggered by your application. Therefore, an event can be something that is generated by a user or something that is generated by the OS. |
|
|
|
|
|
|
|
|
When you begin to program for the Windows environment, youll learn about common visual components such as command buttons, text boxes, list boxes, and combo boxes. Users may click a button, type data into a text box, click a list box, or drop down a combo box. The component then receives an event, such as a mouse click, and has a chance to respond to the event. An event that is not handled is either discarded or a default action may be taken by the system. |
|
|
|
|
|
|
|
|
Table 1.2 shows you the events that you may respond to on a command button. |
|
|
|
|
| Table 1.2 Examples of Command Button Events. | | Event Name | Description | | Click | The button is clicked on with the mouse or keyboard. | | MouseMove | Occurs when the mouse moves over a command button. |
|
|
|
|
|
|
Different objects will have different events that you respond to. Table 1.3 shows you some of the events for a text box. You can see that there are different events youll respond to. |
|
|
|
|
|